package com.zx.wangyixinwen.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;

import com.android.volley.toolbox.NetworkImageView;
import com.zx.wangyixinwen.MyRequestQueue;
import com.zx.wangyixinwen.R;
import com.zx.wangyixinwen.adapter.WomanPagerAdapter;
import com.zx.wangyixinwen.bean.Woman;
import com.zx.wangyixinwen.bean.WomanBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dllo on 16/1/24.
 */
public class WomanAcitivy extends Activity {
    private WomanPagerAdapter adapter;
    private ViewPager viewPager;
    private List<Woman> datas;
    private List<View> listViews;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_woman);
        viewPager = (ViewPager) findViewById(R.id.woman_viewpager);
        Intent intent = getIntent();
        int pos = intent.getIntExtra("pos", 0);
        datas = (List<Woman>) intent.getSerializableExtra("datas");
        int size = datas.get(0).getData().getArticle().get(pos).getImage().size();
        listViews = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            View view = LayoutInflater.from(this).inflate(R.layout.item_woman_pager_adapter, null);
            NetworkImageView nv = (NetworkImageView) view.findViewById(R.id.iv_pageradapter);
            String url = datas.get(0).getData().getArticle().get(pos).getUrl();
               MyRequestQueue.setNetImage(nv, url);
            listViews.add(view);
        }

        adapter = new WomanPagerAdapter(listViews, this);
        viewPager.setAdapter(adapter);

    }

}
